import {defineStore} from "pinia";

import useFastnavStore from './fastnav'

const useAuthStore = defineStore('appAuth', {
    state: () => {
        return {
            isLogin: false,
            _userInfo: null,
        }
    },

    persist: true,

    getters: {
        userInfo(): IUser | null {
            return this._userInfo
        }
    },

    actions: {
        login(data: any) {
            this.isLogin = true
            this._userInfo = data
        },

        logout() {
            useFastnavStore().logout()

            this.$reset()
        },
    },
})
export default useAuthStore
